package com.sinven.serviceImpl;

import com.sinven.dao.UserDao;
import com.sinven.entity.User;
import com.sinven.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service("UserService")
@Transactional
public class UserServiceImpl implements UserService{


    @Autowired
    @Qualifier(value = "UserDao")
    private UserDao userDao;


    @Override
    public List<User> findUser() {
        String hql = "from User";
        return userDao.findUser(hql);
    }



    @Override
    public User findUserByCode(String username, String password) {
        User user = null;
        List<User> userList = userDao.findUserByCode(username,password);
        for(User u : userList){
            user = u;
        }
        return user;
    }


    @Override
    public int RegisteredUser(User user) {
        Integer integer = userDao.RegisteredUser(user);
        return integer;
    }

    @Override
    public int upLoginTime(Date lastLoginTime,String username) {
        int result = userDao.upLoginTime(lastLoginTime,username);
        return result;
    }
}
